<%@ page pageEncoding="ISO-8859-1" contentType="text/html; charset=ISO-8859-1" %>
<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<script type="text/javascript" src="scripts/defscripts.js"></script>
<fmt:setBundle basename="MessageResources"/>

<form name="elementForm" method="post" action="${param['formAction']}">
	<table border="0" cellpadding="1" align="center">
		<tr>
			<td align="right"><fmt:message key="food.name"/>:</td>
			<td><input name="element.name" type="text" size="30" value="${element.name}"></td>
		</tr>
		<tr>
			<td align="right" valign="top"><fmt:message key="food.components"/>:</td>
			<td>
				<input name="foodComponentsListSize" type="hidden" id="foodComponentsListSize" value="0">
				<fmt:message key="food.component.name"/> / <fmt:message key="food.component.percentage"/><br>
				<div id="foodComponentsList"></div>
				<input name="addFoodComponentButton" type="button" value="<fmt:message key='food.register.form.addFoodComponentButton.label'/>" onclick="addFoodComponent('foodComponentsList','foodComponentsListSize','componentName','componentPergentage')">
				<script type="text/javascript">
					for (i = 0; i < 5; i++) document.elementForm.addFoodComponentButton.click();
					<c:forEach items="${element.compositions}" var="eachComponent" varStatus="eachId">
						if (${eachId.count - 1} >= document.elementForm.foodComponentsListSize.value) document.elementForm.addSymptomButton.click();
						document.elementForm.componentName${eachId.count - 1}.value = ${eachComponent.name};
						document.elementForm.componentPergentage${eachId.count - 1}.value = ${eachComponent.percentage};
					</c:forEach>
				</script>
			</td>
		</tr>
		<tr>
			<td colspan="2" align="center">
				<input name="submit" type="submit" value="<fmt:message key='element.form.submit.label'/>">
				<input name="clear" type="reset" value="<fmt:message key='element.form.clear.label'/>">
				<input name="back" type="button" value="<fmt:message key='element.form.back.label'/>" onclick="location.href='${backPage}'">
			</td>
		</tr>
	</table>
</form>
